package day06;

import java.util.Arrays;
import java.util.Scanner;

public class MaxOfArrays1 {
    public static void main(String[] args) {
        Scanner scanner=  new Scanner(System.in);
        System.out.println("输入数组的长度和最大数");
        int len = scanner.nextInt();
        int maxs = scanner.nextInt();
        int[] arr = new int[len];
        for (int i = 0;i<arr.length;i++){
            arr[i]= (int) (Math.random()*maxs);
        }
        int max = arr[0];
        for (int i = 1; i<arr.length;i++){
            if (arr[i]>max){
                max = arr[i];
            }
        }
        arr = Arrays.copyOf(arr,arr.length+1);
        arr[arr.length-1] = max;
        System.out.println(Arrays.toString(arr));
    }
}
